/*
 *  Copyright (C) 2010 Interactive Media Management
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package dk.i2m.converge.ejb.facades;

import dk.i2m.converge.core.search.SearchEngineIndexingException;
import dk.i2m.converge.core.content.MediaItem;
import dk.i2m.converge.core.content.NewsItem;
import dk.i2m.converge.domain.search.SearchResults;
import javax.ejb.Local;

/**
 * Local interface for the Search Engine service.
 *
 * @author Allan Lykke Christensen
 */
@Local
public interface SearchEngineLocal {

    /**
     * Queries the search engine.
     *
     * @param query
     *          Query string
     * @param start
     *          First record to retrieve
     * @param rows
     *          Number of rows to retrieve
     * @param filterQuerties
     *          Filter queries to include in the search
     * @return {@link SearchResults} matching the {@code query}
     */
    SearchResults search(String query, int start, int rows, String ... filterQueries);

    /**
     * Indexes a given {@link NewsItem}.
     * 
     * @param newsItem
     *          {@link NewsItem} to index
     */
    void index(NewsItem ni) throws SearchEngineIndexingException;

    /**
     * Indexes a given {@link MediaItem}.
     *
     * @param mediaItem
     *          {@link MediaItem} to index
     */
    void index(MediaItem mi) throws SearchEngineIndexingException;

    /**
     * Removes a given entry from the search engine based on its unique
     * identifier.
     *
     * @param item
     *          NewsItem to remove from the index
     */
    void removeFromIndex(NewsItem item) throws SearchEngineIndexingException;

    /**
     * Removes a given entry from the search engine based on its unique
     * identifier.
     *
     * @param item
     *          MediaItem to remove from the index
     */
    void removeFromIndex(MediaItem item) throws SearchEngineIndexingException;
}
